/**
 * @param {number[][]} mat
 * @param {number[][]} target
 * @return {boolean}
 */
 var findRotation = function(mat, target) {
    const n = mat.length
    const helper = (mat) => {
        for(let i = 0; i<n-1; i++){
            for(let j = i; j<n-1-i; j++){
                [mat[i][j],mat[n-1-j][i],mat[n-1-i][n-1-j],mat[j][n-1-i]] = [mat[n-1-j][i],mat[n-1-i][n-1-j],mat[j][n-1-i],mat[i][j]]
            }
        }
    }
    const check = (mat, target) => {
        for(let i = 0; i<n; i++){
            for(let j = 0; j<n; j++){
                if(mat[i][j] !== target[i][j])
                    return false
            }
        }
        return true
    }
    for(let i = 0; i<=4; i++){
        helper(mat)
        if(check(mat, target)){
            return true
        }
    }
    return false
};